<?php 

/**
*Form Builder & Admin Generator

*@author marcio <opi14@op.pl>, <polishvodka7@gmail.com>
*@copyright Copyright (c) 2011, marcio
*@version 1.6.5
*/

require_once('abstract/View.php');

class Standard_View extends Volta_View
{

	/**
	*Metoda zwraca na gotowy formularz do wyswietlenia
	*@access public 
	*@return string
	*/
	public function render()
	{
		$view = $this -> get_form_tag('open');
		
		$view .= '<table align="center" style="background-color:#778899;border:2px solid #800000;">';
		
		foreach($this -> get_elements() as $key => $html)
		{
			if($this -> is_hidden_element($this -> get_element($key)))
				$view .= $this -> get_element($key);
			else
				$view .= '<tr><td><b>'.$key.':</b></td><td>'.$this -> get_element($key).'</td></tr>';
		}
		
		$view .= '<tr><td align="right">'.$this -> get_form_tag('submit').'</td></tr>';
		$view .= '</table>';
		$view .= $this -> get_form_tag('close');
		
		if(sizeof($this -> errors) > 0)
		{
			$view .= '<table align="center">';
			
			foreach($this -> get_errors() as $error)
				$view .= '<tr><td align="center"><div style="padding:5px;margin:5px;background-color:#C0C0C0;border:1px solid #ff0033;"><b>'.$error.'</b></div></td></tr>';
			
			$view .= '</table>';
		}
		
		if(!empty($this -> message))
			$view .= '<div align="center" style="padding:5px;margin:5px;background-color:#C0C0C0;border:1px solid #33ff33;">'.$this -> get_message().'</div>';
		
		return $view;
	}

}
?>